package com.ruoyi.mas.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mas.domain.MasPay;
import com.ruoyi.mas.service.IMasPayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪资信息Controller
 * 
 * @author xiaotang
 * @date 2022-03-22
 */
@RestController
@RequestMapping("/mas/pay")
public class MasPayController extends BaseController
{
    @Autowired
    private IMasPayService masPayService;

    /**
     * 查询薪资信息列表
     */
    @PreAuthorize("@ss.hasPermi('mas:pay:list')")
    @GetMapping("/list")
    public TableDataInfo list(MasPay masPay)
    {
        startPage();
        List<MasPay> list = masPayService.selectMasPayList(masPay);
        return getDataTable(list);
    }

    /**
     * 导出薪资信息列表
     */
    @PreAuthorize("@ss.hasPermi('mas:pay:export')")
    @Log(title = "薪资信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MasPay masPay)
    {
        List<MasPay> list = masPayService.selectMasPayList(masPay);
        ExcelUtil<MasPay> util = new ExcelUtil<MasPay>(MasPay.class);
        util.exportExcel(response, list, "薪资信息数据");
    }

    /**
     * 获取薪资信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('mas:pay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(masPayService.selectMasPayById(id));
    }

    /**
     * 新增薪资信息
     */
    @PreAuthorize("@ss.hasPermi('mas:pay:add')")
    @Log(title = "薪资信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MasPay masPay)
    {
        return toAjax(masPayService.insertMasPay(masPay));
    }

    /**
     * 修改薪资信息
     */
    @PreAuthorize("@ss.hasPermi('mas:pay:edit')")
    @Log(title = "薪资信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MasPay masPay)
    {
        return toAjax(masPayService.updateMasPay(masPay));
    }

    /**
     * 删除薪资信息
     */
    @PreAuthorize("@ss.hasPermi('mas:pay:remove')")
    @Log(title = "薪资信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(masPayService.deleteMasPayByIds(ids));
    }
}
